using System;
using System.Collections.Generic;
using System.Text;
using TVDesigner.Entities.Elements;

namespace TVDesigner.Generator.GeneratorEntities
{
    public class HTextGenerator : GenericComponentGenerator
    {
        private HText _HText;

        public HTextGenerator(HText hText)
            : base(hText)
        {
            _HText = hText;
        }
        public override string TypeString
        {
            get { return "org.havi.ui.HText"; }
        } 

        protected override void _SetAttributes(StringBuilder sb)
        {
            if (_HText.Text != null && !_HText.Text.Equals(string.Empty))
            {
                sb.Append("\t\t\tthis.").Append(_HText.NameStartedWithLowerCase).Append(".setHorizontalAlignment(org.havi.ui.HText.HALIGN_LEFT);\n");
                sb.Append("\t\t\tthis.").Append(_HText.NameStartedWithLowerCase).Append(".setVerticalAlignment(org.havi.ui.HText.VALIGN_TOP);\n");

                sb.Append("\t\t\tthis.").Append(_HText.NameStartedWithLowerCase).Append(".setTextContent(\"").Append(_HText.Text).Append("\", org.havi.ui.HVisible.ALL_STATES);\n");
                sb.Append("\t\t\tjava.awt.Font font = new java.awt.Font(\"Arial Black\", java.awt.Font.PLAIN, 20);\n");
                sb.Append("\t\t\tthis.").Append(_HText.NameStartedWithLowerCase).Append(".setFont(font);\n");

                sb.Append("\t\t\tjava.awt.Color color = new java.awt.Color(").Append(_HText.Foreground.ToArgb()).Append(");\n");
                sb.Append("\t\t\tthis.").Append(_HText.NameStartedWithLowerCase).Append(".setForeground(color);\n");

                sb.Append("\t\t\tjava.awt.Color backgroundColor = new java.awt.Color(").Append(_HText.Background.ToArgb()).Append(");\n");
                sb.Append("\t\t\tthis.").Append(_HText.NameStartedWithLowerCase).Append(".setBackground(backgroundColor);\n");
            }
        }
    }
}
